home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 027a / clip5not.zip / S50003.TXT < prev   
Text File  |  1990-10-08  |  17KB  |  372 lines

  1. CLIPPER 5.0 SUPPORT BULLETIN #3
  2.  
  3. BULLETIN REVISED: 04 Oct. 1990
  4.  
  5. PRODUCT: Clipper 5.0
  6.  
  7. AFFECTED VERSIONS: Rev. 1.00 - 1.03
  8.  
  9. SUBJECT: Clipper 5.0 runtime memory management
  10.  
  11.  
  12. This document provides information on the Clipper 5.0 runtime
  13. memory management system.
  14.  
  15. Note: this document makes several references to the CLIPPER
  16. environment variable.  For general information on how to
  17. configure the runtime environment, refer to the Clipper 5.0
  18. "Programming and Utilities Guide."
  19.  
  20.  
  21. VIRTUAL MEMORY MANAGER (VMM)
  22.   
  23.   "Virtual memory" is a generic term for hardware or software
  24.   techniques that allow a limited amount of "real" memory to
  25.   emulate a much larger "virtual" memory.
  26.   
  27.   The Clipper 5.0 Virtual Memory Manager (VMM) is implemented in
  28.   software.  The system runs in real mode on any 8086-compatible
  29.   processor; it does not directly use the protected mode virtual
  30.   memory capabilities of the Intel 286 and 386 processors.
  31.   
  32.   The VMM is a "segmented" memory manager.  Virtual memory is
  33.   allocated in segments, each of which may contain from 1K to 64K
  34.   of data.  Initially, the VMM works somewhat like a normal
  35.   memory allocator (although it has an extra advantage: most VM
  36.   segments are movable; the VMM can reorganize them to get
  37.   maximum utilization of real memory).  Unlike a normal memory
  38.   allocator, however, the VMM does not "run out" when the
  39.   available real memory can no longer contain all of the
  40.   allocated segments.  Instead, one or more of the least recently
  41.   used (LRU) segments are "swapped out" into secondary storage
  42.   (or otherwise removed from real memory, see below) to make room
  43.   for new segments.  Later, if data in a swapped segment must be
  44.   accessed, it is swapped back in, displacing segments which are
  45.   not currently needed.
  46.   
  47.   The maximum virtual address space of the Clipper 5.0 VMM is
  48.   64MB.
  49.   
  50.  
  51. USE OF LIM 3.2 EXPANDED MEMORY (EMM)
  52.   
  53.   By default, the Clipper 5.0 VMM uses LIM 3.2 Expanded Memory
  54.   (EMM) as secondary storage.  EMM provides fast access to
  55.   swapped segments.  Up to 8MB of EMM can be used.
  56.   
  57.   CONFIGURATION: EMM usage can be controlled using the E setting
  58.   in the CLIPPER environment variable.  Valid settings are from 0
  59.   to 8192 (units of 1K).  A setting of 0 disables the use of EMM
  60.   altogether.  (Note: disabling EMM is not recommended under
  61.   Clipper 5.0.  Although EMM is not required, it allows increased
  62.   performance for most applications.  In a few cases, limiting
  63.   EMM usage may be desirable -- see the note below under DISK
  64.   BUFFERING SYSTEM.)
  65.   
  66.   Example:  SET CLIPPER=E2048
  67.   
  68.   CONFIGURATION: Some disk caching programs use EMM to cache disk
  69.   sectors.  Certain cache programs may cause conflicts with the
  70.   Clipper 5.0 VMM system if they assume that application programs
  71.   never use EMM.  The BADCACHE setting in the CLIPPER environment
  72.   variable causes the VMM to preserve and restore the state of
  73.   the EMM "page frame" before and after every EMM access (the EMM
  74.   page frame is an area in real address space through which EMM
  75.   data is accessed).  This should make Clipper's use of EMM
  76.   undetectable to any other process using EMM.  (Note: on some
  77.   EMM systems the BADCACHE setting may adversely affect VMM
  78.   performance.  It should only be used if you experience disk or
  79.   file corruption because of a conflict with a disk cache or
  80.   other resident software.)
  81.   
  82.   Example:  SET CLIPPER=BADCACHE
  83.   
  84.  
  85. DISK SWAPPING
  86.   
  87.   If insufficient EMM is available to contain swapped segments, a
  88.   temporary disk file (the "swap file") is created to hold them. 
  89.   By default, the VMM will use a maximum of 8MB of disk space for
  90.   the swap file.  Disk space is used only as needed.
  91.   
  92.   CONFIGURATION:  The maximum size of the disk swap file can be
  93.   controlled using the SWAPK setting in the CLIPPER environment
  94.   variable.  Valid settings are from 256 to 64000 (256K to
  95.   64MB).  The SWAPK setting has no effect on VMM swapping
  96.   activity; it merely serves to establish an upper limit on the
  97.   size of the swap file.  If the limit is exceeded, the VMM will
  98.   terminate the application.
  99.   
  100.   Example:  SET CLIPPER=SWAPK:16000
  101.   
  102.   CONFIGURATION: The disk drive and directory where the VMM swap
  103.   file is created can be controlled using the SWAPPATH setting in
  104.   the CLIPPER environment variable.  By default, the swap file is
  105.   created in the current DOS directory.
  106.   
  107.   Example:  SET CLIPPER=SWAPPATH:"C:\SWAP"
  108.   
  109.  
  110. SWAP SPACE
  111.   
  112.   The term "swap space" refers to the region of real memory where
  113.   the VMM loads virtual memory segments.
  114.   
  115.   CONFIGURATION: The VMM allocates the swap space from DOS at
  116.   startup.  By default, all available DOS memory is used for swap
  117.   space.  Real memory usage can be restricted using the X setting
  118.   of the CLIPPER environment variable.  The setting specifies an
  119.   amount of DOS memory (in 1K units) which is to be excluded from
  120.   the VMM.  Valid settings are from 0 to 256.  The X setting is
  121.   provided as a way to reserve DOS memory for other uses (e.g.
  122.   allocation by memory-resident software).  In general, its use
  123.   is undesirable because limiting the swap space decreases VMM
  124.   performance.
  125.   
  126.   Example:  SET CLIPPER=X8
  127.   
  128.  
  129. OBJECT MEMORY (SVOS)
  130.   
  131.   An "object memory" is a special type of memory manager designed
  132.   to manage complex data values such as character strings and
  133.   arrays.
  134.   
  135.   The Clipper 5.0 object memory is called the Segmented Virtual
  136.   Object Store (SVOS).  SVOS uses virtual memory to store data
  137.   values, including character strings, arrays, and dynamically
  138.   created (macro-compiled) code blocks.
  139.   
  140.   SVOS provides two important functions beyond the basic
  141.   capabilities offered by the VMM:
  142.   
  143.   - Memory compaction: stored values are automatically compacted
  144.   on an ongoing basis.  This eliminates fragmentation of the
  145.   virtual memory and reduces swapping.
  146.   
  147.   - Garbage collection: Some Clipper 5.0 values (e.g. arrays) may
  148.   be referred to by several program variables (or array elements)
  149.   at the same time.  The garbage collection algorithms
  150.   automatically reclaim space occupied by "unreachable" values
  151.   (values which are no longer accessible through any variable or
  152.   array).
  153.   
  154.   To minimize delays associated with memory compaction and
  155.   garbage collection, the SVOS algorithms are dynamically
  156.   adjusted based on the type, size, and persistence of data being
  157.   stored, the amount of memory available (real and EMM), and the
  158.   overall performance of the system.  The algorithms attempt to
  159.   manage memory in such a way that the VMM can swap out
  160.   infrequently used data, freeing up real address space for
  161.   time-critical operations.
  162.   
  163.   The dynamic nature of the SVOS algorithms makes it difficult to
  164.   precisely state its maximum capacity.  The worst case capacity
  165.   is in excess of 1MB.  The theoretical maximum is in excess of
  166.   16MB.  
  167.   
  168.   
  169. DYNAMIC OVERLAYING
  170.   
  171.   Clipper 5.0, using the supplied special version of .RTLink,
  172.   manages compiled Clipper code using a technique called dynamic
  173.   overlaying.  This technique eliminates the need for complicated
  174.   overlay structures and allows flexible runtime management of
  175.   compiled code.
  176.   
  177.   During linking, .RTLink breaks compiled Clipper modules into
  178.   fixed-size "pages."  These pages are stored either in the
  179.   executable file or in separate overlay files.  The paging
  180.   architecture eliminates restrictions and memory calculations
  181.   based on the size of compiled functions or modules.  Large
  182.   modules are broken into multiple pages; small functions are
  183.   grouped together in a single page.
  184.   
  185.   At execution time, the dynamic overlay manager loads pages
  186.   based on information embedded in the .EXE by the linker.  The
  187.   dynamic pages are loaded into VM segments, allowing the VMM to
  188.   manage the overlay pages on a competetive basis with other uses
  189.   of memory.  The paging architecture allows the system to
  190.   discard low-use sections of code even if the code is associated
  191.   with a pending active function; overlays are not required to
  192.   "nest" in parallel with function activations.  Code pages which
  193.   are being heavily used are maintained in memory by the VMM's
  194.   LRU swapping policy.
  195.   
  196.   When possible, the VMM will place dynamic overlay pages in EMM,
  197.   reducing overlay reads.  Overlay pages are never written to the
  198.   VMM disk swap file, however.  If a VM segment containing an
  199.   overlay page is to be removed from memory altogether, it is
  200.   simply discarded.  If it is needed subsequently, it is re-read
  201.   from the overlay file.
  202.   
  203.   CONFIGURATION:  In addition to virtual memory, the dynamic
  204.   overlay manager uses a dedicated area of real memory to cache
  205.   the most active dynamic overlay pages.  The default size of
  206.   this area ranges from 4K to 16K, depending on the amount of
  207.   real memory available at startup.  For low memory situations,
  208.   the size of this area can be restricted using the DYNK setting
  209.   of the CLIPPER environment variable.  Valid values are from 4
  210.   to 63.  (Note: restricting the size of this area may reduce
  211.   execution speed.)
  212.   
  213.   Example:  SET CLIPPER=DYNK:4
  214.   
  215.   CONFIGURATION:  The dynamic overlay manager will hold overlay
  216.   pages in virtual memory only as long as it can maintain an
  217.   active file handle for the disk file containing the pages.  If
  218.   the file is closed, the pages are discarded from virtual
  219.   memory.  The maximum number of file handles used by the dynamic
  220.   overlay manager can be controlled using the DYNF setting of the
  221.   CLIPPER environment variable.  Valid settings are from 1 to 8. 
  222.   The default setting is 2.  For applications which use many
  223.   separate overlay files, increasing this setting can improve
  224.   performance.
  225.   
  226.   Example:  SET CLIPPER=DYNF:4
  227.   
  228.   
  229. DATA FILE BUFFERING
  230.   
  231.   The Clipper 5.0 database drivers use virtual memory segments to
  232.   contain database and index file buffers.  This allows the VMM
  233.   to manage these buffers on a competetive basis with other uses
  234.   of memory.  As with dynamic overlay segments, the VMM will swap
  235.   buffer segments into EMM but not to the disk swap file.  If a
  236.   VM segment containing a disk buffer is to be removed from
  237.   memory altogether, it is written back to the appropriate data
  238.   file.
  239.   
  240.   The file buffering system allocates buffer management tables in
  241.   fixed memory (see FIXED MEMORY ALLOCATOR below).  The actual
  242.   amount used depends on the combined total of real memory and
  243.   EMM available at startup.  The tables use 14 bytes per 1K of
  244.   real or Expanded memory (the tables never exceed 8K, however). 
  245.   Because these tables are allocated in fixed memory, they have
  246.   an effect on the amount of swap space available to the VMM.  In
  247.   some low-memory situations, reducing the amount of available
  248.   EMM may help to avoid "swap space exhausted" errors. (Note:
  249.   reducing EMM availability may seriously degrade VMM performance
  250.   in very low memory situations due to increased disk swapping --
  251.   see USE OF LIM 3.2 EXPANDED MEMORY above.)
  252.   
  253.   
  254. SEGMENT LOCKING
  255.   
  256.   From time to time, certain VM segments are "locked" by a
  257.   subsystem.  This prevents the VMM from moving or swapping those
  258.   segments until the subsystem unlocks them.  This capability is
  259.   used sparingly to keep the swap space from becoming cluttered
  260.   with locked segments.
  261.   
  262.   
  263. FIXED MEMORY ALLOCATOR
  264.   
  265.   Clipper 5.0 subsystems use virtual memory to contain code or
  266.   data that needs to be dynamically managed.  Some allocations
  267.   are not appropriate for VM (e.g. system tables which must
  268.   remain in the same location throughout execution).  A C-style
  269.   fixed memory allocator is included for this purpose.  The fixed
  270.   memory system allocates one or more VM segments and permanently
  271.   locks them in real memory.  Space within these segments is then
  272.   parceled out as needed.  Since fixed segments are never
  273.   unlocked, the VMM locates them at the low end of the swap space
  274.   to prevent them from interfering with other operations.
  275.   
  276.   
  277. MEMVAR TABLES
  278.   
  279.   Clipper 5.0 offers several different storage classes for
  280.   program variables.  Local and static variables are stored in a
  281.   dedicated area of real memory.  Private and public (MEMVAR)
  282.   variables are stored in VM segments.  Since MEMVAR variables
  283.   are created and destroyed dynamically during execution, the
  284.   associated VM segments grow dynamically depending on how many
  285.   MEMVAR variables are in use.  For performance reasons, these
  286.   segments remain locked during most operations (they are
  287.   unlocked during RUN commands and certain other memory intensive
  288.   operations).  In low memory situations, the MEMVAR tables may
  289.   have a significant effect on the amount of available swap space
  290.   (each MEMVAR variable uses 20 bytes in the MEMVAR segments,
  291.   which grow in increments of 1K or more).  MEMVAR variables also
  292.   require symbol information to be maintained at runtime (see
  293.   below).  Converting private and public variables to local and
  294.   static variables may reduce memory requirements for some
  295.   applications.
  296.   
  297.  
  298. SYMBOL TABLES
  299.   
  300.   Clipper maintains symbol information at runtime in order to
  301.   support symbolic references to variables and functions.  Some
  302.   symbol information is embedded in the .EXE file (the Clipper
  303.   5.0 version of .RTLink eliminates duplication among symbols
  304.   from compiled Clipper modules).  Other symbols are created
  305.   dynamically at runtime.  Memory for symbol tables and related
  306.   information is allocated using the fixed memory allocator.  The
  307.   symbols are allocated in blocks and do not fragment memory. 
  308.   However, excessive dynamic symbol creation (e.g. large numbers
  309.   of MEMVAR variables created via macros) may cause the symbol
  310.   tables to grow, reducing swap space.
  311.   
  312.  
  313. THE EXTEND SYSTEM
  314.   
  315.   The Extend system is a set of functions that are used by C and
  316.   assembly language programs to interface with Clipper programs. 
  317.   The Extend system includes two memory allocation functions,
  318.   _xalloc() and _xgrab(), which allow C programs to allocate
  319.   memory from Clipper.  These functions call the fixed memory
  320.   allocator (see above).
  321.   
  322.   The Extend system also allows C programs to gain access to
  323.   Clipper data values.  The Extend system _parc() function, used
  324.   to inspect character values passed from Clipper, is defined as
  325.   returning an address in real memory.  Since character values
  326.   are stored in virtual memory under SVOS (see above), the Extend
  327.   system automatically locks the appropriate VM segments in
  328.   response to _parc() requests.  The segments are automatically
  329.   unlocked when the C function returns control to Clipper (they
  330.   may also be unlocked manually from C, see below).
  331.   
  332.   A conflict can occur if a C function locks a VM segment via
  333.   _parc() and then attempts to allocate a large amount of memory
  334.   using the Extend allocators.  If the segment is locked near the
  335.   low end of the swap space, the fixed allocator may be unable to
  336.   lock or expand a fixed segment to satisfy the allocation
  337.   request.  If this occurs, a new fixed segment is created and
  338.   locked higher in memory.  This reduces memory efficiency
  339.   because the VMM is not allowed to move fixed segments (in
  340.   severe cases, the VMM may issue a "swap space exhausted" error
  341.   because the swap space has become too cluttered with fixed
  342.   segments).  To prevent this, the VMM maintains a "safety zone"
  343.   at the low end of the swap space.  _parc() requests are
  344.   prevented from locking segments within this zone.
  345.   
  346.   CONFIGURATION: The size of the Extend "safety zone" can be
  347.   adjusted using the EXTHEAP setting of the CLIPPER environment
  348.   variable.  The default setting is 8K.  Valid settings are from
  349.   2 to 256 (units of 1K).  Increasing the safety zone allows C
  350.   programs to allocate large amounts of memory without creating
  351.   "holes" in the swap space.  (Note: the default EXTHEAP setting
  352.   should be sufficient for most applications; increasing the
  353.   value too much may cause the VMM to fail when trying to lock a
  354.   segment in response to a _parc() request.)
  355.   
  356.   NEW EXTEND FUNCTION: The Clipper 5.0 VMM defines an entry point
  357.   called _xunlock().  This function can be called from C or
  358.   assembly language programs to unlock SVOS segments when large
  359.   amounts of memory are to be allocated after _parc() has been
  360.   called.  CAUTION: calling _xunlock() causes any pointers
  361.   returned from previous _parc() calls to become invalid.  To
  362.   access a Clipper character value after calling _xunlock(), you
  363.   must make another call to _parc() to get a new pointer.
  364.   
  365.   Nantucket will be publishing an API (Application Program
  366.   Interface) for the Clipper 5.0 VMM so that C and assembly
  367.   language programs can allocate virtual memory directly,
  368.   reducing demands on swap space.
  369.   
  370.   
  371. END: CLIPPER 5.0 SUPPORT BULLETIN #3
  372.